#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 7;
struct car {
    int d, v, a;
}a[SIZE];
int T;
int n, m, l, v;
int p[SIZE], b[SIZE], cnt[SIZE];
int ans1, ans2;
struct SegmentTree {
    int l, r;
    int dat;
}t[SIZE * 2];
void build(int p, int l, int r){
    if (l == r){
        t[p].dat = cnt[l];
        return;
    }
    int mid = (l + r) >> 1;
    build(p * 2, l, mid);
    build(p * 2 + 1, mid + 1, r);
    t[p].dat = max(t[p * 2].dat, t[p * 2 + 1].dat);
}
int ask(int p, int l, int r){
    if (t[p].l <= l && t[p].r >= r) return t[p].dat;
    int mid = (t[p].l + t[p].r) >> 1;
    int res = -(1 << 30);
    if (l <= mid) res = max(res, ask(p * 2, l, mid));
    if (r > mid) res = max(res, ask(p * 2 + 1, mid + 1, r));
    return res;
}
double calcv(int v0, int a, int s){
    double x = (double)v0 * v0 + 2 * a * s;
    return sqrt(max((double)0, x));
}
void solve(){
    ans1 = ans2 = 0;
    memset(b, 0, sizeof b);
    memset(cnt, 0, sizeof cnt);
    memset(t, 0, sizeof t);
    scanf("%d%d%d%d", &n, &m, &l, &v);
    for (int i = 1; i <= n; i ++) scanf("%d%d%d", &a[i].d, &a[i].v, &a[i].a);
    for (int i = 1; i <= m; i ++) scanf("%d", &p[i]);
    sort(p + 1, p + m + 1);
    build(1, 1, m);
    for (int i = 1; i <= n; i ++){
        int x = lower_bound(p, p + m, a[i].d) - p;
        if (a[i].a > 0 && calcv(a[i].v, a[i].a, p[m] - a[i].d) > (double)v){
            ans1 ++;
            double s = max((double)(v * v - a[i].v * a[i].v) / (a[i].a * 2) + a[i].d, (double)0);
            int y = lower_bound(p, p + m, s) - p + 1;
            for (int j = y; j <= m; j ++) printf("%d ", j);
            b[ask(1, y, m)] ++;
        }else if (a[i].a < 0 && (calcv(a[i].v, a[i].a, p[x] - a[i].d) > (double)v || calcv(a[i].v, a[i].a, p[x + 1] - a[i].d) > (double)v || calcv(a[i].v, a[i].a, p[x - 1] - a[i].d) > (double)v)){
            ans1 ++;
            double s = max((double)(v * v - a[i].v * a[i].v) / (a[i].a * 2) + a[i].d, (double)0);
            int y = upper_bound(p, p + m, s) - p - 1 - 1;
            b[ask(1, x, y + 1)] ++;
        }else if (a[i].a == 0 && a[i].v > v){
            ans1 ++;
        }
    }
    for (int i = 1; i <= m; i ++)
        if (!b[i]) ans2 ++;
    bool flag = 1;
    for (int i = 1; i <= n; i ++)
        if (a[i].a != 0){
            flag = 0;
            break;
        }
    if (flag) ans2 = m - 1;
    printf("%d %d\n", ans1, ans2);
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while (T --) solve();
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15

3 3
*/